'''
Created on Dec 4, 2009

@author: tliu
'''
from google.appengine.ext import db
from error.TagError import TagError as TagError

def createTagging(tagged_user, tags):
    tag = Tagging(tagged_user = tagged_user,
                  tags = tags)
    tag.put()
    return tag
    
class Tagging(db.Model):
    from User import User
    tagged_user = db.ReferenceProperty(User, required=True)
    tags = db.StringListProperty(required=True)
    
    def __str__(self):
        return "hello there I am a function"
    
    def setTags(self, tags):
        self.tags = tags
        self.put()
    
    def removeTag(self, tag):
        try:
            self.tags.remove(tag)
        except ValueError:
            pass
        self.put()

